package com.grgbanking.it.common;

import java.util.List;

import org.apache.jcs.JCS;
import org.apache.jcs.access.exception.CacheException;
import org.apache.log4j.Logger;

import com.grgbanking.it.system.entity.Department;

/**
 * 系统缓存
 * 
 * SystemCache
 * 
 * @author 潘广伟
 * @Email p_3er@qq.com
 * @Date 2014-12-15 下午4:30:16
 * 
 * @version 1.0.0
 *
 */
public class SystemCache {
	private static Logger log = Logger.getLogger(LogAspect.class);
	//对象缓冲池
	private static JCS cache;
	static{
		try {
			cache = JCS.getInstance("systemCache");
		} catch (Exception e) {
			log.error("获取对象缓存出错!" + e);
		}
	}
	
	
	public static void setDepartmentTree(String tree) throws CacheException{
		cache.put("departmentTree", tree);
	}
	
	public static String getDepartmentTree(){
		return (String) cache.get("departmentTree");
	}
	
	public static void setAllDepartment(List<Department> departments) throws CacheException{
		cache.put("departments", departments);
	}
	
	@SuppressWarnings("unchecked")
	public static List<Department>  getAllDepartments(){
		return (List<Department>) cache.get("departments");
	}
}
